﻿using IGeekFan.AspNetCore.Knife4jUI;
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Text;

namespace XTemplate.Core.Swagger
{
    public static class SwaggerApplicationExtensions
    {
        public static IApplicationBuilder UseCoreSwagger(this IApplicationBuilder app)
        {
            app.UseSwagger();

            app.UseKnife4UI(c =>
            {
                c.RoutePrefix = "swagger"; // serve the UI at root
                c.SwaggerEndpoint("/v1/api-docs", "V1 Docs");
            });

            //app.UseSwaggerUI(option =>
            //{
            //    option.SwaggerEndpoint("/swagger/v1/swagger.json", "spd DepartmentApp api v1");
            //});

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapSwagger("{documentName}/api-docs");
            });

            return app;
        }
    }
}
